<?php

/**
 * login actions.
 *
 * @package    courier
 * @subpackage login
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class loginActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
    $this -> formulario = new IdentificaForm();
	if ($request -> isMethod('post')){
		$login = $request -> getParameter("login");
		$password = $request -> getParameter("password");
		$criteria = new Criteria();
		$criteria = add -> (EmpleadoPeer::EMP_LOGIN,$login);
		$criteria = add -> (EmpleadoPeer::EMP_PASS,$password);
		$empleado = EmpleadoPeer::doSelectOne($criteria);
			if($empleado!=''){
		            $this->getUser()->setAuthenticated(true);
			    $this->getUser()->setAttribute('emp_id',$empleado->getEmpId()); 				    $this->getUser()->setAttribute('empleado_nombre',$empleado->getEmpNombre().' '.$empleado->getEmpApellido());
                            if($empleado->getEmpPerfil()=='despachador'){
				$this -> redirect();	
				}
			    else ($empleado->getEmpPerfil()=='recolector'){
				$this -> redirect();
				}
			}
  	}
}
